package com.yunzhong.appointment.report.controller;

import com.yunzhong.appointment.report.service.IAnnualDepartmentAppointmentStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @className AnnualDepartmentAppointmentStatisticsController
 * @description 年度科室预约统计
 * @author 朱洪宇
 * @time 2019年12月18日
 */
@RequestMapping("forms")
@Controller
public class AnnualDepartmentAppointmentStatisticsController {
	@Autowired
	private IAnnualDepartmentAppointmentStatisticsService iAnnualDepartmentAppointmentStatisticsService;
	/**
	 * 
	 * @methodName deptapp
	 * @description 转页
	 * @author 朱洪宇
	 * @time 2019年12月18日
	 */
	@RequestMapping("deptapp")
	public  String deptapp(){
		return "report/report/annualdepartmentappointmentstatistics";
	}
	/**
	 *
	 * @methodName deptapp
	 * @description 年度科室预约统计
	 * @param data1
	 * @author 朱洪宇
	 * @time 2019年12月18日
	 */
	@RequestMapping("view")
	@ResponseBody
	public Map<String,Long> queryCountByDept(String data1){
			List<Map<String, Object>> list =iAnnualDepartmentAppointmentStatisticsService.queryCountByDept(data1);
			Map<String, Long> map = new LinkedHashMap<>();
			for( Map<String, Object> m : list) {
				map.put(String.valueOf(m.get("name")), (Long)m.get("num"));
			}
		return map;
	}
	/**
	 *
	 * @methodName queryDataForExcel
	 * @description 年度科室预约统计为了生成表格数据
	 * @param appyear
	 * @author 朱洪宇
	 * @time 2019年12月18日
	 */
	@RequestMapping("queryDataForExcel")
	@ResponseBody
	public Map<String,Long> queryDataForExcel(String appyear){
			List<Map<String, Object>> list =iAnnualDepartmentAppointmentStatisticsService.queryCountByDept(appyear);
			Map<String, Long> map = new LinkedHashMap<>();
			for( Map<String, Object> m : list) {
				map.put(String.valueOf(m.get("name")), (Long)m.get("num"));
			}
		return map;
	}




}
